﻿package net.wangit.dev.table;

import net.wangit.jdbc.DB;
import net.wangit.util.Checker;
import net.wangit.view.page.PageCache;
import net.wangit.view.unit.UnitCache;

public class TableReferenceUtil {

	private static final String SQL_REFERENCE = "update UNIT set t=? where t=?";

	public TableReferenceUtil() {
	}

	public static void update(DB db, String domain, String oldTableId,
			String newTableId) throws Exception {
		if (!Checker.isEmpty(oldTableId) && !oldTableId.equals(newTableId)) {
			db.execute(TableReferenceUtil.SQL_REFERENCE, new String[] {
					newTableId, oldTableId }, new int[] { 2, 2 });
			UnitCache.clearAll(domain);
			PageCache.clearAll(domain);
		}
	}
}
